package com.cgwx.common.enums;

import com.cgwx.common.utils.EnumUtils;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Optional;

/**
 * 预约类型
 */
public enum OrderType implements InfoEnum{
    NORMAL("正常","NORMAL"),
    JUMP_QUEUE("插队","JUMP_QUEUE"),
    URGENT("加急","URGENT");
    private String info;
    private String code;

    @JsonValue
    public String getInfo() {
        return info;
    }

    public String getCode() {
        return code;
    }

    OrderType(String info, String code) {
        this.info = info;
        this.code = code;
    }

    public static String getNumByInfo(String info){
        Optional<OrderType> m1 = EnumUtils.getEnumObject(OrderType.class, e -> e.getInfo().equals(info));
        return m1.isPresent() ? m1.get().code : null;
    }


    @Override
    public String getSelfCode() {
        return this.code;
    }

    @Override
    public String getSelfInfo() {
        return this.info;
    }
}
